package com.uphone.magicleafteacher.pro.activity;

import android.graphics.Color;
import android.view.View;

import com.radish.baselibrary.Intent.IntentData;
import com.radish.baselibrary.Intent.IntentUtils;
import com.uphone.magicleafteacher.MyApp;
import com.uphone.magicleafteacher.base.BaseListActivity;
import com.uphone.magicleafteacher.http.ApiService;
import com.uphone.magicleafteacher.pro.adapter.StudentRankAdapter;
import com.uphone.magicleafteacher.util.GsonUtils;
import com.uphone.magicleafteacher.vo.StudentRankBean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

public class StudentRankActivity extends BaseListActivity<StudentRankBean.GradesBean, StudentRankAdapter> {
    @IntentData
    private int selectId;

    @Override
    protected Observable<ResponseBody> loadData(ApiService apiService) {
        return MyApp.apiService(ApiService.class)
                .getGradeId();
    }

    @Override
    protected List<StudentRankBean.GradesBean> getDataList(String json) {
        StudentRankBean bean = GsonUtils.getGson().fromJson(json, StudentRankBean.class);
        if (bean != null)
            return bean.getGrades();
        return null;
    }

    @Override
    protected void itemClick(StudentRankAdapter adapter, View view, int position) {
        IntentUtils.getInstance().with()
                .putInt("rankSelectBackId", mAdapter.getItem(position).getGradeId())//多选
                .putString("rankSelectBackName", mAdapter.getItem(position).getGradeName())
                .setResultAndFinish(this, 100);
    }

    @Override
    protected StudentRankAdapter initAdapter() {
        return new StudentRankAdapter(selectId);
    }

    @Override
    protected void initBundle() {
        isDividerLine = false;

    }

    @Override
    protected void initTitle() {
        ll.setBackgroundColor(Color.WHITE);
        initTitle("学生级别");
    }
}
